#include "junix.h"
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/bind.hpp>

using namespace std;

struct A: boost::noncopyable
{
	int n;
	A(int i) : n(i) { }
	void print() {
		cout<<n<<"\n";
	}
};


void f() {
	typedef boost::ptr_vector<A> PTRV;
	PTRV pv;
	int const size = 10000000;
	for (int i=0;i<size;i++) {
		pv.push_back( new A(i) );
	}

	for_each(pv.begin(), pv.end(),
			boost::bind(&A::print, _1));
}

int main(int argc, char **argv)
{

	typedef boost::ptr_vector<A> PTRV;
	int const size = 10000;

	while (true) {
		PTRV pv;
		for (int i=0;i<size;i++) {
			pv.push_back( new A(i) );
		}

		pv.clear();
	}
}
